﻿Public Class Formato2
    Dim negrita As Boolean = False
    Dim cursiva As Boolean = False
    Dim subrayado As Boolean = False
    Dim negritaf As FontStyle
    Dim cursivaf As FontStyle
    Dim subrayadof As FontStyle
    Dim negritaf1 As FontStyle
    Dim cursivaf1 As FontStyle
    Dim subrayadof1 As FontStyle
    Dim tamaño As String = "8"
    Dim Fuente As String = "Arial"
    Dim tam As Integer

    Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
        negrita = Not negrita
        If negrita Then
            negritaf = FontStyle.Bold
        Else
            negritaf = FontStyle.Regular
        End If
        Actualiza()
    End Sub

    Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged
        cursiva = Not cursiva
        If cursiva Then
            cursivaf = FontStyle.Italic
        Else
            cursivaf = FontStyle.Regular
        End If
        Actualiza()
    End Sub

    Private Sub CheckBox3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox3.CheckedChanged
        subrayado = Not subrayado
        If subrayado Then
            subrayadof = FontStyle.Underline
        Else
            subrayadof = FontStyle.Regular
        End If
        Actualiza()
    End Sub

    Private Sub CheckBox4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox4.CheckedChanged
        CheckBox1.Checked = False
        CheckBox2.Checked = False
        CheckBox3.Checked = False
        Me.RichTextBox1.Font = New System.Drawing.Font(RichTextBox1().Font, FontStyle.Regular)

    End Sub

    Public Sub Actualiza()
        CheckBox4.Checked = False
        tam = CInt(tamaño)
        Me.RichTextBox1.Font = New System.Drawing.Font(Fuente, tam, CType(((negritaf Or cursivaf) Or subrayadof), System.Drawing.FontStyle))
    End Sub

    Private Sub Formato2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim i As Integer
        For i = 8 To 12
            ListBox1.Items.Add(i)
        Next i
        For i = 14 To 28 Step +2
            ListBox1.Items.Add(i)
        Next i
        Dim lista As FontFamily
        For Each lista In System.Drawing.FontFamily.Families
            ComboBox1.Items.Add(lista.Name)
        Next
        ComboBox1.SelectedItem = Fuente
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        ColorDialog2.AllowFullOpen = True
        ColorDialog2.AnyColor = True
        If ColorDialog2.ShowDialog() = DialogResult.OK Then
            RichTextBox1.ForeColor = ColorDialog2.Color
        End If
    End Sub

    Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
        RichTextBox1.ForeColor = Color.Red
    End Sub

    Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
        RichTextBox1.ForeColor = Color.Blue
    End Sub

    Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton3.CheckedChanged
        RichTextBox1.ForeColor = Color.Yellow
    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        Fuente = ComboBox1.Items(ComboBox1.SelectedIndex)
        Actualiza()
    End Sub

    Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
        Dim i As Integer
        For i = 0 To ListBox1.SelectedIndices.Count - 1
            tamaño = ListBox1.Items(ListBox1.SelectedIndices(0))
            Actualiza()
        Next i
    End Sub
    Public Sub fuenteperson()
        RichTextBox1.SelectionFont = New Font(Fuente, tam, CType(((negritaf1 Or cursivaf1) Or subrayadof1), System.Drawing.FontStyle))
    End Sub

    Private Sub NegritaToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NegritaToolStripMenuItem1.Click
        RichTextBox1.SelectionFont = New Font(Fuente, tam, FontStyle.Bold)
    End Sub

    Private Sub CursivaToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CursivaToolStripMenuItem1.Click
        RichTextBox1.SelectionFont = New Font(Fuente, tam, FontStyle.Italic)
    End Sub

    Private Sub SubrayadoToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SubrayadoToolStripMenuItem1.Click
        RichTextBox1.SelectionFont = New Font(Fuente, tam, FontStyle.Underline)
    End Sub

    Private Sub RegularToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RegularToolStripMenuItem1.Click
        RichTextBox1.SelectionFont = New Font(Fuente, tam, FontStyle.Regular)
    End Sub

    Private Sub RegularToolStripMenuItem_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RegularToolStripMenuItem.Click
        resetear()
        RichTextBox1.SelectionFont = New Font(Fuente, tam, FontStyle.Regular)
    End Sub

    Private Sub CursivaToolStripMenuItem_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CursivaToolStripMenuItem.Click
        Me.CursivaToolStripMenuItem.Checked = True
        If CursivaToolStripMenuItem.Checked Then
            cursivaf1 = FontStyle.Italic
        Else
            cursivaf1 = FontStyle.Regular
        End If
        fuenteperson()
    End Sub

    Private Sub NegritaToolStripMenuItem_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NegritaToolStripMenuItem.Click
        Me.NegritaToolStripMenuItem.Checked = True
        If NegritaToolStripMenuItem.Checked Then
            negritaf1 = FontStyle.Bold
        Else
            negritaf1 = FontStyle.Regular
        End If
        fuenteperson()
    End Sub

    Private Sub SubrayadoToolStripMenuItem_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SubrayadoToolStripMenuItem.Click
        Me.SubrayadoToolStripMenuItem.Checked = True
        If SubrayadoToolStripMenuItem.Checked Then
            subrayadof1 = FontStyle.Underline
        Else
            subrayadof1 = FontStyle.Regular
        End If
        fuenteperson()
    End Sub

    Private Sub VariosFormatosALaVesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles VariosFormatosALaVesToolStripMenuItem.Click
        resetear()
    End Sub
    Public Sub resetear()
        Me.CursivaToolStripMenuItem.Checked = False
        Me.SubrayadoToolStripMenuItem.Checked = False
        Me.NegritaToolStripMenuItem.Checked = False
        subrayadof1 = FontStyle.Regular
        negritaf1 = FontStyle.Regular
        negritaf1 = FontStyle.Regular
    End Sub

    Private Sub ColorEspecificoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ColorEspecificoToolStripMenuItem.Click
        ColorDialog2.AllowFullOpen = True
        ColorDialog2.AnyColor = True
        If ColorDialog2.ShowDialog() = DialogResult.OK Then
            RichTextBox1.SelectionColor = ColorDialog2.Color
        End If
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Me.Visible = False
        Principal.Visible = True
    End Sub
End Class